package com.jkgh.remedium.states;

import com.jkgh.asin.State;
import com.jkgh.asin.StateMachine;

public abstract class GatheringState extends State {

	private int needed;

	public GatheringState(StateMachine machine) {
		super(machine);
	}
	
	public GatheringState(StateMachine machine, int needed) {
		super(machine);
		this.needed = needed;
	}

	@Override
	public void onBytesAvailable() {
		if (machine.getBytesAvailable() >= needed) {
			onNeededBytesAvailable();
		}
	}

	protected abstract void onNeededBytesAvailable();

	public void setNeeded(int needed) {
		this.needed = needed;
	}

}
